﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace UnitTests
{
	public partial class TextList : UserControl
	{
		private static readonly Brush redBrush = new SolidColorBrush(Colors.Red);
		public TextList()
		{
			InitializeComponent();
		}

		public void PrintFail(params object[] stuff)
		{
			this.PrintImpl(true, stuff);
		}

		public void Print(params object[] stuff)
		{
			this.PrintImpl(false, stuff);
		}

		private void PrintImpl(bool useRed, params object[] stuff)
		{
			string output = string.Empty;
			if (stuff.Length > 0)
			{
				output = this.SafeToString(stuff[0]);
				for (int i = 1; i < stuff.Length; ++i)
				{
					output += " " + this.SafeToString(stuff[i]);
				}
			}
			TextBlock text = new TextBlock() { Text = output };
			if (useRed)
			{
				text.Foreground = redBrush;
			}

			this.text_output.Children.Add(text);
			this.scroller.ScrollToVerticalOffset(double.PositiveInfinity);
		}

		private string SafeToString(object something)
		{
			if (something == null) { return "null"; }

			return something.ToString();
		}
	}
}
